package com.tanxi521.afkrewards.util;

import com.tanxi521.afkrewards.data.AfkData;
import com.tanxi521.afkrewards.entity.PlayerAfk;
import com.tanxi521.afkrewards.entity.PlayerMaxRewards;
import com.tanxi521.afkrewards.main.AfkRewards;

import java.util.Date;
import java.util.List;
import java.util.TimerTask;

public class Task extends TimerTask {
    public void run() {
        long time = new Date().getTime();
        AfkRewards.getInstance().getServer().broadcastMessage("[挂机]正在准备重置挂机次数限制");
        List<PlayerAfk> playerList = AfkData.getPlayerList();
        for (PlayerAfk playerAfk : playerList) {
            PlayerMaxRewards playerMaxRewards = new PlayerMaxRewards();
            playerMaxRewards.setUuid(playerAfk.getPlayer_uuid());
            playerMaxRewards.setMaxTimes(0);
            AfkData.setPlayerMaxTime(playerMaxRewards);
        }
        long time1 = new Date().getTime();
        AfkRewards.getInstance().getServer().broadcastMessage("[挂机]挂机次数限制重置完成,耗时 " + (time1 - time) + " 毫秒");
    }
}
